/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.router.core.repository.entity;

import com.gitee.peigenlpy.actable.annotation.Column;
import com.gitee.peigenlpy.actable.annotation.Index;
import com.gitee.peigenlpy.actable.annotation.Table;
import com.gitee.peigenlpy.actable.annotation.Unique;
import com.gitee.peigenlpy.actable.constants.MySqlCharsetConstant;
import com.gitee.peigenlpy.actable.constants.MySqlEngineConstant;
import com.gitee.peigenlpy.actable.constants.MySqlTypeConstant;
import info.peigen.hotpot.business.router.facade.enums.ChannelCode;
import info.peigen.hotpot.business.router.facade.enums.RouterAction;
import info.peigen.hotpot.common.core.enums.Currency;
import info.peigen.hotpot.common.core.lang.money.Money;
import info.peigen.hotpot.component.data.repository.beetlsql.entity.AbstractCreateTimeEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.handler.MoneyBeetlSqlHandler;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;

import java.util.Date;

/**
 * <b>(RouterTransLogEntity)</b>
 * 通用网关交易记录表
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/4/25
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
@Table(name = "router_trans_log", comment = "通用网关交易记录表", charset = MySqlCharsetConstant.UTF8MB4, engine = MySqlEngineConstant.InnoDB)
@org.beetl.sql.annotation.entity.Table(name = "router_trans_log")
public class RouterTransLogEntity extends AbstractCreateTimeEntity {
    @Column(name = "trans_log_id", type = MySqlTypeConstant.VARCHAR, length = 35, isNull = false, comment = "transLogId")
    @Unique(value = "transLogId", columns = "trans_log_id")
    @org.beetl.sql.annotation.entity.Column("trans_log_id")
    String transLogId;

    @Column(name = "action", type = MySqlTypeConstant.VARCHAR, length = 50, isNull = false, comment = "路由行为")
    @org.beetl.sql.annotation.entity.Column("action")
    @Index(value = "action", columns = "action")
    RouterAction action;

    @Column(name = "code", type = MySqlTypeConstant.VARCHAR, length = 50, isNull = false, comment = "渠道Code,和action一起用确定唯一")
    @org.beetl.sql.annotation.entity.Column("code")
    @Index(value = "code", columns = "action,code")
    ChannelCode code;

    @Column(name = "payer_account_name", type = MySqlTypeConstant.VARCHAR, length = 200, isNull = false, comment = "付款方账户名")
    @org.beetl.sql.annotation.entity.Column("payer_account_name")
    String payerAccountName;

    @Column(name = "payer_account_no", type = MySqlTypeConstant.VARCHAR, length = 35, isNull = false, comment = "付款方账号")
    @org.beetl.sql.annotation.entity.Column("payer_account_no")
    @Index(value = "payerAccountNo", columns = "payer_account_no")
    String payerAccountNo;

    @Column(name = "payer_account_currency", type = MySqlTypeConstant.VARCHAR, length = 3, isNull = false, comment = "付款方币种")
    @org.beetl.sql.annotation.entity.Column("payer_account_currency")
    Currency payerAccountCurrency;

    @Column(name = "payee_account_name", type = MySqlTypeConstant.VARCHAR, length = 200, isNull = false, comment = "收款方账户名")
    @org.beetl.sql.annotation.entity.Column("payee_account_name")
    String payeeAccountName;

    @Column(name = "payee_account_no", type = MySqlTypeConstant.VARCHAR, length = 35, isNull = false, comment = "收款方账号")
    @org.beetl.sql.annotation.entity.Column("payee_account_no")
    @Index(value = "payeeAccountNo", columns = "payee_account_no")
    String payeeAccountNo;

    @Column(name = "payee_account_currency", type = MySqlTypeConstant.VARCHAR, length = 3, isNull = false, comment = "收款方币种")
    @org.beetl.sql.annotation.entity.Column("payee_account_currency")
    Currency payeeAccountCurrency;

    @Column(name = "trans_amount", type = MySqlTypeConstant.VARCHAR, length = 65, isNull = false, defaultValue = "0.00", comment = "交易金额")
    @org.beetl.sql.annotation.entity.Column("trans_amount")
    @MoneyBeetlSqlHandler
    Money transAmount;

    @Column(name = "fee_amount", type = MySqlTypeConstant.VARCHAR, length = 65, isNull = false, defaultValue = "0.00", comment = "收费金额")
    @org.beetl.sql.annotation.entity.Column("fee_amount")
    @MoneyBeetlSqlHandler
    Money feeAmount;

    @Column(name = "fee_currency", type = MySqlTypeConstant.VARCHAR, length = 3, comment = "收费币种")
    @org.beetl.sql.annotation.entity.Column("fee_currency")
    Currency feeCurrency;

    @Column(name = "trans_date", type = MySqlTypeConstant.DATETIME, isNull = false, comment = "交易日期")
    @Index(value = "transDate", columns = "trans_date")
    @org.beetl.sql.annotation.entity.Column("trans_date")
    Date transDate;

    @Column(name = "batch_no", type = MySqlTypeConstant.VARCHAR, length = 50, comment = "批次号")
    @Index(value = "batchNo", columns = "batch_no")
    @org.beetl.sql.annotation.entity.Column("batch_no")
    String batchNo;

    @Column(name = "trade_id", type = MySqlTypeConstant.VARCHAR, length = 50, comment = "交易系统ID")
    @org.beetl.sql.annotation.entity.Column("trade_id")
    @Index(value = "tradeId", columns = "trade_id")
    String tradeId;

    @Column(name = "gateway_uni_id", type = MySqlTypeConstant.VARCHAR, length = 50, comment = "网关返回的唯一ID")
    @org.beetl.sql.annotation.entity.Column("gateway_uni_id")
    @Index(value = "gatewayUniId", columns = "gateway_uni_id")
    String gatewayUniId;

    @Column(name = "channel_uni_id", type = MySqlTypeConstant.VARCHAR, length = 50, comment = "渠道返回的唯一ID")
    @org.beetl.sql.annotation.entity.Column("channel_uni_id")
    @Index(value = "channelUniId", columns = "channel_uni_id")
    String channelUniId;

    @Column(name = "request_json", type = MySqlTypeConstant.JSON, length = 4000, comment = "渠道请求原始报文")
    @org.beetl.sql.annotation.entity.Column("request_json")
    String requestJson;

    @Column(name = "response_json", type = MySqlTypeConstant.JSON, length = 4000, comment = "渠道响应原始报文")
    @org.beetl.sql.annotation.entity.Column("response_json")
    String responseJson;

    @Column(name = "memo", type = MySqlTypeConstant.VARCHAR, length = 50, comment = "memo")
    @org.beetl.sql.annotation.entity.Column("memo")
    String memo;

    @Column(name = "payee_account_security_id", type = MySqlTypeConstant.VARCHAR, length = 35, comment = "收款方账号安全ID")
    @org.beetl.sql.annotation.entity.Column("payee_account_security_id")
    @Index(value = "payeeAccountSecurityId", columns = "payee_account_security_id")
    String payeeAccountSecurityId;
}